import request from './request'

export const moduleApi = {
  // 获取模块列表
  getModules(productName, version, params = {}) {
    return request.get(`/products/${productName}/${version}/modules`, { params })
  },

  // 获取模块详情
  getModuleDetail(moduleId, productName, version) {
    return request.get(`/products/${productName}/${version}/modules/${moduleId}/details`)
  },

  // 获取模块依赖关系
  getModuleDependencies(moduleId, productName, version) {
    return request.get(`/products/${productName}/${version}/deps/${moduleId}/symbols`)
  },

  // 获取模块符号信息
  getModuleSymbols(moduleId, productName, version) {
    return request.get(`/products/${productName}/${version}/modules/${moduleId}/fields`, {
      params: { type: 'symbols' }
    })
  },

  // 获取模块字段信息（用于依赖图等）
  getModuleFields(moduleId, productName, version, type = 'deps') {
    return request.get(`/products/${productName}/${version}/modules/${moduleId}/fields`, {
      params: { type }
    })
  },

  // 获取模块统计信息
  getModuleStats(productName, version) {
    return request.get(`/products/${productName}/${version}/modules/stats`)
  },

  // 获取图数据
  getGraphData(productName, version, graphType, params = {}) {
    return request.get(`/graphviz/${productName}/${version}/${graphType}`, { params })
  },

  // 获取分析数据
  getAnalysisData(productName, version, params = {}) {
    return request.get(`/analysis/${productName}/${version}`, { params })
  },

  // 获取仪表板数据
  getDashboardData(productName, version) {
    return request.get(`/dashboard/${productName}/${version}`)
  },

  // 获取热门模块（按依赖数量）
  getTopModules(productName, version, limit = 10) {
    return request.get(`/products/${productName}/${version}/modules/top`, {
      params: { limit }
    })
  },

  // 获取模块类型分布
  getModuleTypeDistribution(productName, version) {
    return request.get(`/products/${productName}/${version}/modules/distribution/types`)
  }
}